package com.example.demo;

// import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
// import springfox.documentation.swagger2.annotations.EnableSwagger2;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;

// @EnableSwagger2 // swagger UI 查看接口用
@SpringBootApplication
// @MapperScan("com.example.demo.mapper") // // 配置类里有就可以了,两处都写也没问题不报错
public class JavaLearningApplication {

	public static void main(String[] args) throws Exception {
		// SpringApplication.run(JavaLearningApplication.class, args);

		ConfigurableApplicationContext application = SpringApplication.run(JavaLearningApplication.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		String property = env.getProperty("server.servlet.context-path");
		String path = property == null ? "" :  property;
		System.out.println(
				"\n\t" +
						"----------------------------------------------------------\n\t" +
						"Application Spring-Boot is running! Access URLs:\n\t" +
						"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
						"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
						"------------------------------------------------------------");
	}

}
